// 引入项目中全部的全局组件
import SvgIcon from '@/components/SvgIcon/index.vue'
import Catagory from '@/components/Catagory/index.vue'
import type { App, Component } from 'vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 全局对象
const allGloballComponent: Record<string, Component> = { SvgIcon, Catagory }

// 对外暴露插件对象
export default {
  // 必须叫做 install 方法
  install(app: App) {
    Object.keys(allGloballComponent).forEach((key) => {
      app.component(key, allGloballComponent[key])
    })
    // 将 element-plus提供的图标注册为全局组件
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
  },
}
